package com.mallcloud.mall.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.app.mapper.AppProcedureMapper;
import com.mallcloud.mall.common.core.exception.FailException;
import com.mallcloud.mall.mall.api.entity.MallMyEnableCouponModel;
import com.mallcloud.mall.mall.api.entity.dto.ProCouponBatchWriteOff;
import com.mallcloud.mall.mall.mapper.MallMyEnableCouponMapper;
import com.mallcloud.mall.mall.service.MallMyEnableCouponService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 可使用券 服务实现类
 * </p>
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class MallMyEnableCouponServiceImpl extends ServiceImpl<MallMyEnableCouponMapper, MallMyEnableCouponModel> implements MallMyEnableCouponService {
	private final AppProcedureMapper procedureMapper;

	@Override
	public String proCouponBatchWriteOff(ProCouponBatchWriteOff dto) {
		procedureMapper.proCouponBatchWriteOff(dto);
		if (!dto.isSuccess()) {
			log.error("失败");
			throw new FailException(dto.getMessage());
		}
		return dto.getBatchWriteOffNumber();
	}
}
